package com.longteng.java.web.dataproducer;


import com.google.common.collect.Lists;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by tianqing.wang
 * DATE : 2018/3/18
 * TIME : 上午1:22
 * PROJECT : java-lesssion
 * PACKAGE : com.gitee.longteng.lession.lesson2.dataproducer
 *
 * @author <a href="mailto:celeskyking@163.com">tianqing.wang</a>
 */
@Component
public class TestDataGenerator implements DataGenerator{


    private NameDataGenerator nameDataGenerator;


    private IDCardDataGenerator idCardDataGenerator;


    private OrderDataGenerator orderDataGenerator;


    private PhoneNumberDataGenerator phoneNumberDataGenerator;

    private TestDataGenerator(){
        this.nameDataGenerator = new NameDataGenerator();
        this.idCardDataGenerator = new IDCardDataGenerator();
        this.orderDataGenerator = new OrderDataGenerator();
        this.phoneNumberDataGenerator = new PhoneNumberDataGenerator();
    }


    @Override
    public DataInfo generate() {
        DataInfo dataInfo = new DataInfo();
        dataInfo.setIdCard(idCardDataGenerator.generate());
        dataInfo.setName(nameDataGenerator.generate());
        dataInfo.setOrder(orderDataGenerator.generate());
        dataInfo.setTelPhone(phoneNumberDataGenerator.generate());
        return dataInfo;
    }


    public List<DataInfo> generate(int size){
        List<DataInfo> lines = Lists.newArrayList();
        for(int i=0;i<size;i++){
            lines.add(generate());
        }
        return lines;
    }


}
